package com.one.component;

import javax.swing.*;
import javax.swing.table.TableModel;

import com.one.util.CheckCodeFromMysql;
import com.one.util.GetBookDataFromSql;

import java.sql.*;

public class BookManagePanel{
    public static void addBook (int bookNumber, String bookName, String author, String publisher, double value, int freeNumber, int total) throws SQLException {
        String url = CheckCodeFromMysql.getUrl();
        Connection connection = DriverManager.getConnection(url, "root", "123456");
        PreparedStatement sql = connection.prepareStatement("insert into books values (?, ?, ?, ?, ?, ?, ?)");
        sql.setInt(1, bookNumber);
        sql.setString(2, bookName);
        sql.setString(3, author);
        sql.setString(4, publisher);
        sql.setDouble(5, value);
        sql.setInt(6, freeNumber);
        sql.setInt(7, total);
        sql.execute();
    }
}
